home *** CD-ROM | disk | FTP | other *** search
/ Network PC / Network PC.iso / amiga utilities / communication / bbs / termv4.6 / extras / source / term-source.lha / Start.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-18  |  3.1 KB  |  154 lines

  1. /*
  2. **    Start.c
  3. **
  4. **    The program entry point
  5. **
  6. **    Copyright © 1990-1996 by Olaf `Olsen' Barthel
  7. **        All Rights Reserved
  8. **
  9. **    :ts=4
  10. */
  11.  
  12. #include <intuition/intuitionbase.h>
  13. #include <workbench/workbench.h>
  14. #include <exec/execbase.h>
  15. #include <dos/dosextens.h>
  16.  
  17. #include <clib/intuition_protos.h>
  18. #include <clib/exec_protos.h>
  19. #include <clib/dos_protos.h>
  20.  
  21. #include <pragmas/intuition_pragmas.h>
  22. #include <pragmas/exec_pragmas.h>
  23. #include <pragmas/dos_pragmas.h>
  24.  
  25. #include <string.h>
  26.  
  27.     /* Standard topaz.font/8. */
  28.  
  29. extern struct TextAttr     DefaultFont;
  30.  
  31.     /* exec.library base pointer. */
  32.  
  33. extern struct ExecBase    *SysBase;
  34.  
  35.     /* The appropriate machine type check. */
  36.  
  37. #if defined(CPU_ANY) || defined(CPU_any)
  38. #define MACHINE_OKAY (1)
  39. #endif
  40.  
  41. #if defined(CPU_68020) || defined(CPU_68030)
  42. #define MACHINE_OKAY (SysBase->AttnFlags & AFF_68020)
  43. #endif
  44.  
  45. #if defined(CPU_68040)
  46. #define MACHINE_OKAY (SysBase->AttnFlags & AFF_68040)
  47. #endif
  48.  
  49.     /* Start():
  50.      *
  51.      *    Program entry point, checks for the right CPU type and
  52.      *    runs the main program if possible.
  53.      */
  54.  
  55. LONG __saveds __stdargs
  56. Start(VOID)
  57. {
  58.         /* Get SysBase. */
  59.  
  60.     SysBase = *(struct ExecBase **)4;
  61.  
  62.         /* Is the minimum required processor type and Kickstart 2.04 (or higher)
  63.          * available?
  64.          */
  65.  
  66.     if(MACHINE_OKAY && (SysBase->LibNode.lib_Version > 37 || (SysBase->LibNode.lib_Version == 37 && SysBase->SoftVer >= 175)))
  67.     {
  68.             // Without the typedef the syntax would make you go nuts...
  69.  
  70.         typedef LONG (* SPINY)(VOID);
  71.  
  72.         extern SPINY SpinyNorman(VOID);
  73.  
  74.         return((*SpinyNorman())());
  75.     }
  76.     else
  77.     {
  78.         struct Process *ThisProcess = (struct Process *)FindTask(NULL);
  79.  
  80.             /* Is a Shell window available? */
  81.  
  82.         if(ThisProcess->pr_CLI)
  83.         {
  84.             struct DosLibrary *DOSBase;
  85.  
  86.                 /* Show the message. */
  87.  
  88.             if(DOSBase = (struct DosLibrary *)OpenLibrary("dos.library",0))
  89.             {
  90.                 STRPTR String;
  91.  
  92.                 if(MACHINE_OKAY)
  93.                     String = "Kickstart 2.04 or higher required.\a\n";
  94.                 else
  95.                     String = "MC68020 or higher required.\a\n";
  96.  
  97.                 Write(Output(),String,strlen(String));
  98.  
  99.                 CloseLibrary(DOSBase);
  100.             }
  101.  
  102.             return(RETURN_FAIL);
  103.         }
  104.         else
  105.         {
  106.             struct IntuitionBase    *IntuitionBase;
  107.             struct WBStartup        *WBenchMsg;
  108.  
  109.                 /* Wait for startup message. */
  110.  
  111.             WaitPort(&ThisProcess->pr_MsgPort);
  112.  
  113.                 /* Get the message. */
  114.  
  115.             WBenchMsg = (struct WBStartup *)GetMsg(&ThisProcess->pr_MsgPort);
  116.  
  117.                 /* Show the message. */
  118.  
  119.             if(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0))
  120.             {
  121.                 STATIC struct IntuiText SorryText = {0,1,JAM1,6,3,&DefaultFont,(STRPTR)"Sorry",NULL};
  122.  
  123.                 struct IntuiText    *Body;
  124.                 LONG                 Width;
  125.  
  126.                 if(MACHINE_OKAY)
  127.                 {
  128.                     STATIC struct IntuiText BodyText = {0,1,JAM1,5,3,&DefaultFont,(STRPTR)"Kickstart 2.04 or higher required.",NULL};
  129.  
  130.                     Body    = &BodyText;
  131.                     Width    = 309;
  132.                 }
  133.                 else
  134.                 {
  135.                     STATIC struct IntuiText BodyText = {0,1,JAM1,5,3,&DefaultFont,(STRPTR)"MC68020 or higher required.",NULL};
  136.  
  137.                     Body    = &BodyText;
  138.                     Width    = 253;
  139.                 }
  140.  
  141.                 AutoRequest(NULL,Body,NULL,&SorryText,NULL,NULL,Width,46);
  142.  
  143.                 CloseLibrary(IntuitionBase);
  144.             }
  145.  
  146.                 /* Return the startup message and exit. */
  147.  
  148.             Forbid();
  149.  
  150.             ReplyMsg((struct Message *)WBenchMsg);
  151.         }
  152.     }
  153. }
  154.